import {request} from "@/api";
import {SysRole} from "@/api/role/types.ts";
import {Page} from "@/api/types.ts";

const apiPrefix = '/varian-system/role'
export const roleApi = {
    add: (data: SysRole) => request.post(`${apiPrefix}`, {data}),
    page: (params: any) => request.get<Page<SysRole>>(`${apiPrefix}/page`, {params}),
    list: (params: any) => request.get<SysRole[]>(`${apiPrefix}/list`, {params}),
    modify: (data: SysRole) => request.put(`${apiPrefix}/${data.id}`, {data}),
    delete: (id: string) => request.delete(`${apiPrefix}/${id}`),
    detail: (id: string) => request.get<SysRole>(`${apiPrefix}/${id}`),
    grantedList: (id: string) => request.get<{ menuIds: string[] }>(`${apiPrefix}/grant/${id}`),
    grant: (data: { id: string, menuIds: string[] }) => request.put(`${apiPrefix}/grant/${data.id}`, {data})
}
